package com.yuyou.fn.tms.controller;


import com.yuyou.fn.tms.service.IStudentQueryService;
import com.yuyou.fn.tms.util.Signs;
import com.yuyou.fn.tms.vo.FindOrSaveStudentParam;
import com.yuyou.fn.tms.vo.ResponseResult;
import com.yuyou.fn.tms.vo.TmsStudent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.validation.Valid;

@Controller
@RequestMapping("/api/data/student")
@Api(tags = "学生")
public class StudentController {

    @Value("${tms.sign.key}")
    private String signKey ;

    @Resource
    private IStudentQueryService studentQueryService ;

    @ApiOperation(value = "新增学生接口")
    @RequestMapping(value = "/findOrSaveStudent" , method = {RequestMethod.POST})
    @ResponseBody
    public ResponseResult<TmsStudent> findOrSaveStudent(@RequestBody @Valid FindOrSaveStudentParam requestParam ){
        Signs.validateKey(requestParam.getKeyString(),requestParam.getTimeNo(),signKey);
        TmsStudent tmsStudent = studentQueryService.query(requestParam);
        return ResponseResult.success(tmsStudent) ;
    }
}
